package com.thirteen.app.service.impl;

import com.thirteen.app.dao.CollegeDao;
import com.thirteen.app.dto.CreatePaperResponse.CollegeDto;
import com.thirteen.app.entity.College;
import com.thirteen.app.service.CollegeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("collegeService")

public class CollegeServiceImpl implements CollegeService {

    @Resource
    CollegeDao collegeDao;

    @Override
    public List<CollegeDto> queryAllCollege() {
        return collegeDao.queryAllCollege();
    }


    @Override
    public College queryById(Integer collegeid) {
        return this.collegeDao.queryById(collegeid);
    }


    @Override
    public Map<String, Object> queryAllByLimit(int offset, int limit) {

        Map<String, Object> map = new HashMap<>();
        map.put("data", this.collegeDao.queryAllByLimit((offset - 1) * offset, limit));
        map.put("count", this.collegeDao.getCollegeCount());
        return map;
    }

    @Override
    public List<College> queryAll() {
        return collegeDao.queryAll();
    }


    @Override
    public boolean insert(College college) {
        return collegeDao.insert(college) > 0;
    }


    @Override
    public boolean update(College college) {
        return this.collegeDao.update(college) > 0;

    }


    @Override
    public boolean deleteById(Integer collegeid) {
        return this.collegeDao.deleteById(collegeid) > 0;
    }

    @Override
    public Integer getCollegeCount() {
        return this.collegeDao.getCollegeCount();
    }


}
